﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using Abp.Domain.Entities;

namespace KelonProud.TableManagement.Domain
{
    [Table("KpTableColumns")]
   public class KelonTableColumn:Entity
    {
        [Column("TableId")]
        public virtual int TableId { get; set; }

        [ForeignKey("TableId")]
        public virtual KelonTable Table { get; set; }

        [Column("Name")]
        public virtual string Name { get; set; }

        [Column("Type")]
        public virtual ColumnType Type { get; set; }

        [Column("Length")]
        public virtual int Length { get; set; }

        [Column("IsNotNull")]
        public virtual bool IsNotNull { get; set; }

        [Column("IsPrimaryKey")]
        public virtual bool IsPrimaryKey { get; set; }

        [Column("ForeignKeyTableId")]
        public virtual int? ForeignKeyTableId { get; set; }

        [ForeignKey("ForeignKeyTableId")]
        public virtual KelonTable ForeignKeyTable { get; set; }

        [Column("ForeignKeyTableName")]
        public virtual string ForeignKeyTableName { get; set; }

        [Column("ForeignKeyColumnId")]
        public virtual int? ForeignKeyColumnId { get; set; }

        [ForeignKey("ForeignKeyColumnId")]
        public virtual KelonTableColumn ForeignKeyColumn { get; set; }

        [Column("ForeignKeyColumnName")]
        public virtual string ForeignKeyColumnName { get; set; }

        [Column("Order")]
        public virtual int Order { get; set; }
    }

    public enum ColumnType:byte
    {
        Varchar,
        Int,
        Double,
        DateTime,
        Blob
    }
}
